﻿// Function handle all cross links
// contain ajax helper class to
// using for ajax action link request
function IsNumeric(sText) {
    var ValidChars = "0123456789";
    var IsNumber = true;
    var Char;
    for (i = 0; i < sText.length && IsNumber == true; i++) {
        Char = sText.charAt(i);
        if (ValidChars.indexOf(Char) == -1) {
            IsNumber = false;
        }
    }
    return IsNumber;
}

//cheeck for Decimal
function IsDecimal(sText) {
    var ValidChars = "0123456789.";
    var IsNumber = true;
    var Char;
    for (i = 0; i < sText.length && IsNumber == true; i++) {
        Char = sText.charAt(i);
        if (ValidChars.indexOf(Char) == -1) {
            IsNumber = false;
        }
    }
    return IsNumber;
}

function isNumberKey(evt) {
	evt = evt || window.event;
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;

	return true;
}

function isPhoneExtNumber(evt) {
	evt = evt || window.event;
	var charCode = (evt.which) ? evt.which : evt.keyCode;
	// check charcode, it's ok if user enter space,(,),-, del character (charCode for + is 43)
	if (charCode == 32 || charCode == 45 || charCode == 46)
		return true;

	if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;

	return true;
}

function isPhoneNumber(evt) {
	evt = evt || window.event;
	var charCode = (evt.which) ? evt.which : evt.keyCode;
	
	// check charcode, it's ok if user enter space,(,),-, del character (charCode for + is 43)
	if (charCode == 32 || charCode == 40 || charCode == 41 || charCode == 45 || charCode == 46)
	    return true;
    
	if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;	

	return true;
}

$(document).ready(function () {
    // Model popup
    // Using fancybox
    $(".preview").fancybox({
        maxWidth: 400,
        maxHeight: 600,
        fitToView: false,
        width: '70%',
        height: '70%',
        autoSize: true,
        closeClick: true,
        openEffect: 'none',
        closeEffect: 'none'
    });
    $(".locked").fancybox({
        maxWidth: 300,
        maxHeight: 120,
        fitToView: false,
        width: '70%',
        height: '70%',
        autoSize: true,
        closeClick: true,
        openEffect: 'none',
        closeEffect: 'none'
    });
    $(".delete").fancybox({
        maxWidth: 300,
        maxHeight: 120,
        fitToView: false,
        width: '70%',
        height: '70%',
        autoSize: true,
        closeClick: true,
        openEffect: 'none',
        closeEffect: 'none'
    });
    $(".cfdelete").fancybox({
        maxWidth: 400,
        maxHeight: 120,
        fitToView: false,
        width: '70%',
        height: '70%',
        autoSize: true,
        closeClick: true,
        openEffect: 'none',
        closeEffect: 'none'
    });
});
